package com.sky.mapper;

import com.sky.entity.AddressBook;
import com.sky.result.Result;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface AddressMapper {
    Result<String> add(AddressBook addressBook);
    @Select("select * from address_book ")
    List<AddressBook> selectAll();
    @Select("select * from address_book where is_default = 1")
    AddressBook getDefault();
    @Select("select * from address_book where id = #{id}")
    AddressBook getById(Long id);
    @Delete("delete from address_book where id = #{id}")
    void deleteById(Long id);
    @Update("update address_book set is_default = 0")
    void updateAllDefault(AddressBook addressBook);
    @Update("update address_book set is_default = 1 where id = #{id}")
    void setDefault(Long id);
}
